<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class Cat extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        if (method_exists($this, $request->method) && $method = $request->method) {
            return $this->$method();
        } else {
            return [
                'id' => $this->id,
                'catname' => $this->catname,
                'type' => $this->type,
                'father_id' => $this->father_id,
                'level' => $this->level,
            ];
        }
    }

    public function getInfo()
    {
        return [
            'id'=>$this->id ,
            'catname'=>$this->catname,
        ];
    }
}
